#!/usr/bin/env bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos8-install-docker.sh | /bin/bash
#
#
############################################################################

# 卸载原来旧的docker
yum remove docker \
    docker-common \
    docker-selinux \
    docker-engine

# 安装依赖
yum install -y yum-utils \
    device-mapper-persistent-data \
    lvm2 \
    epel-release \
    git

# 添加docker源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 安装docker
yum -y install docker-ce

# 国内加速
mkdir -p /etc/docker
REGISTRY_MIRRORS='{"registry-mirrors":["http://f1361db2.m.daocloud.io/","https://reg-mirror.qiniu.com/"]}'
echo ${REGISTRY_MIRRORS} >/etc/docker/daemon.json

# 安装docker-compose（需要python3.9.2已经先安装好）
# pip install -I docker-compose

# 启动 && 开机启动
systemctl enable docker
systemctl start docker

VERSION=$(docker --version)
echo -e "\n当前docker版本为：${VERSION} \n"
